/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package webServices;

import businessLogic.LoanMgr;
import javax.ejb.EJB;
import javax.jws.WebService;
import javax.ejb.Stateless;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import persistence.Loan;
import persistence.Medium;

/**
 *
 * @author breinesg
 */
@WebService(serviceName = "PublicService")
@Stateless()
public class PublicService {
    @EJB
    private LoanMgr ejbRef;// Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Web Service Operation")

    @WebMethod(operationName = "loanMedium")
    public Medium loanMedium(@WebParam(name = "id") int id, @WebParam(name = "firstName") String firstName, @WebParam(name = "lastName") String lastName) {
        return ejbRef.loanMedium(id, firstName, lastName);
    }

    @WebMethod(operationName = "returnMedium")
    @Oneway
    public void returnMedium(@WebParam(name = "id") int id) {
        ejbRef.returnMedium(id);
    }

    @WebMethod(operationName = "searchMedium")
    public Medium searchMedium(@WebParam(name = "title") String title) {
        return ejbRef.searchMedium(title);
    }

    @WebMethod(operationName = "reserveMedium")
    @Oneway
    public void reserveMedium(@WebParam(name = "id") int id) {
        ejbRef.reserveMedium(id);
    }

    @WebMethod(operationName = "cancelReservation")
    @Oneway
    public void cancelReservation(@WebParam(name = "id") int id) {
        ejbRef.cancelReservation(id);
    }

    @WebMethod(operationName = "askOwnState")
    public Loan askOwnState(@WebParam(name = "firstName") String firstName, @WebParam(name = "lastName") String lastName) {
        return ejbRef.askOwnState(firstName, lastName);
    }
    
}
